//
//  detailViewController.m
//  Wtracker
//
//  Created by Anna on 6/29/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "detailViewController.h"
#import "WtrackerAppDelegate.h"

#define BARBUTTON(TITLE, SELECTOR) [[[UIBarButtonItem alloc] initWithTitle:TITLE style:UIBarButtonItemStylePlain target:self action:SELECTOR] autorelease]

@implementation detailViewController

@synthesize  myDict, cellStr, sectionTitle, theTextField, theTextLabel ;


#pragma mark -
#pragma mark View lifecycle

- (void)viewDidLoad {
    [super viewDidLoad];
	WtrackerAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
	myDict = appDelegate.myDict;
	
	theTextField.delegate = self;
	NSLog(@"sectionTitle: %@", sectionTitle);
	
	self.navigationItem.title = sectionTitle;
	self.navigationItem.rightBarButtonItem = BARBUTTON(@"Save", @selector(saveSettings));
	theTextField.text = cellStr;
	theTextLabel.text = sectionTitle;
}


#pragma mark custom methods
-(IBAction)saveSettings{
	[myDict setObject:theTextField.text forKey:sectionTitle];
	[myDict setValue:[NSNumber numberWithInt:1] forKey:@"Started" ];
	WtrackerAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
	appDelegate.myDict = myDict;	
	NSLog(@"my dict: %@", myDict);
	[appDelegate saveSettings];
	
	[self.navigationController popViewControllerAnimated:YES];
}


- (BOOL)textFieldShouldReturn:(UITextField *)textField {
	[textField resignFirstResponder];
	return YES;
}


#pragma mark -
#pragma mark Table view delegate




- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
}

- (void)viewDidUnload {
  
}


- (void)dealloc {
	
    [super dealloc];
	
}


@end

